home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt3sp1.arc
/
KFIXFNAM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-10-02
|
3KB
|
72 lines
(*----------------------------------------------------------------------*)
(* Fix_File_Name --- Fix file name from remote to be MS DOS style *)
(*----------------------------------------------------------------------*)
FUNCTION Fix_File_Name( FileName : AnyStr ) : AnyStr;
(*----------------------------------------------------------------------*)
(* *)
(* Procedure: Fix_File_Name *)
(* *)
(* Purpose: Fixes received file name to be MS DOS style *)
(* *)
(* Calling Sequence: *)
(* *)
(* Fixed_Name := Fix_File_Name( FileName : AnyStr ) : AnyStr; *)
(* *)
(* FileName --- name of file from remote system *)
(* *)
(*----------------------------------------------------------------------*)
VAR
Temp_Name : AnyStr;
Suffix : STRING[3];
I : INTEGER;
Dot_Found : BOOLEAN;
Done : BOOLEAN;
BEGIN (* Fix_File_Name *)
Suffix := '';
Temp_Name := '';
Dot_Found := FALSE;
Done := FALSE;
I := LENGTH( FileName );
REPEAT
CASE Dot_Found OF
TRUE: BEGIN
IF FileName[I] <> '.' THEN
Temp_Name := UpCase( FileName[I] ) + Temp_Name;
END;
FALSE: IF FileName[I] = '.' THEN
BEGIN
Dot_Found := TRUE;
IF ( LENGTH( Temp_Name ) <= 3 ) THEN
Suffix := Temp_Name
ELSE
Suffix := COPY( Temp_Name, 1, 3 );
Temp_Name := '';
END
ELSE
Temp_Name := UpCase( FileName[I] ) + Temp_Name;
END (* CASE *);
I := I - 1;
Done := Done OR ( I < 1 );
UNTIL Done;
IF ( LENGTH( Temp_Name ) > 8 ) THEN
Temp_Name := COPY( Temp_Name, 1, 8 );
IF Dot_Found THEN
Temp_Name := Temp_Name + '.' + Suffix;
Fix_File_Name := Temp_Name;
END (* Fix_File_Name *);